#ifndef __RATED_LIMIT_H
#define __RATED_LIMIT_H
#include <stdint.h>


#define RATED_LIMIT_TYPE_ENTIRE        1 /* 充放一体 */
#define RATED_LIMIT_TYPE_SEPARATE      2 /* 充放分开 */


/* 选择限额类型 */
#define RATED_LIMIT_TYPE_SEL           RATED_LIMIT_TYPE_ENTIRE           
// #define RATED_LIMIT_TYPE_SEL           RATED_LIMIT_TYPE_SEPARATE     


typedef enum
{
    /* Group_0 */
    RATED_LIMIT_OWNER_0,
        RATED_LIMIT_OWNER_MODULE_TEMP_DIFF = RATED_LIMIT_OWNER_0,           /* 模块温差 */
    RATED_LIMIT_OWNER_1,
        RATED_LIMIT_OWNER_HIGH_TEMP_DERATE = RATED_LIMIT_OWNER_1,           /* 高温降额 */ 
    RATED_LIMIT_OWNER_2,
        RATED_LIMIT_OWNER_REACTOR_OVER_TEMP = RATED_LIMIT_OWNER_2,          /* 电抗器过温 */
    RATED_LIMIT_OWNER_3,
        RATED_LIMIT_OWNER_BUS_CAP_OVER_TEMP = RATED_LIMIT_OWNER_3,          /* 母排电容过温 */
    RATED_LIMIT_OWNER_4,
        RATED_LIMIT_OWNER_FILTER_CAP_OVER_TEMP = RATED_LIMIT_OWNER_4,       /* 滤波电容过温 */
    RATED_LIMIT_OWNER_5,
        RATED_LIMIT_OWNER_AC_CABNET_OVER_TEMP = RATED_LIMIT_OWNER_5,        /* 交流柜过温 */
    RATED_LIMIT_OWNER_6,
        RATED_LIMIT_OWNER_TRANSFORMER_OVER_TEMP = RATED_LIMIT_OWNER_6,      /* 控制变压器过温 */
    RATED_LIMIT_OWNER_7,
        RATED_LIMIT_OWNER_TRANSFORMER_OIL_TEMP_ALARM = RATED_LIMIT_OWNER_7, /* 升压变油温报警 */
    RATED_LIMIT_OWNER_8,
        RATED_LIMIT_OWNER_1547_P_LIMIT = RATED_LIMIT_OWNER_8,               /* 1547有功限制 */
    RATED_LIMIT_OWNER_9,
    RATED_LIMIT_OWNER_10,
    RATED_LIMIT_OWNER_11,
    RATED_LIMIT_OWNER_12,
    RATED_LIMIT_OWNER_13,
    RATED_LIMIT_OWNER_14,
    RATED_LIMIT_OWNER_15,
    /* Group_1 */
    RATED_LIMIT_OWNER_16,
        RATED_LIMIT_OWNER_COMMUNICATION_EMS = RATED_LIMIT_OWNER_16,           /* EMS通讯 */
    RATED_LIMIT_OWNER_17,
        RATED_LIMIT_OWNER_COMMUNICATION_LC = RATED_LIMIT_OWNER_17,            /* LC通讯 */
    RATED_LIMIT_OWNER_18,
        RATED_LIMIT_OWNER_COMMUNICATION_BMS = RATED_LIMIT_OWNER_18,           /* BMS通讯 */
    RATED_LIMIT_OWNER_19,
        RATED_LIMIT_OWNER_COMMUNICATION_DCDC = RATED_LIMIT_OWNER_19,          /* DCDC通讯 */
    RATED_LIMIT_OWNER_20,
    RATED_LIMIT_OWNER_21,
    RATED_LIMIT_OWNER_22,
    RATED_LIMIT_OWNER_23,
    RATED_LIMIT_OWNER_24,
        RATED_LIMIT_OWNER_COMMUNICATION_HMI = RATED_LIMIT_OWNER_24,           /* HMI通讯 */
    RATED_LIMIT_OWNER_25,
        RATED_LIMIT_OWNER_COMMUNICATION_ISO_BOARD = RATED_LIMIT_OWNER_25,     /* 绝缘板通讯 */
    RATED_LIMIT_OWNER_26,
        RATED_LIMIT_OWNER_COMMUNICATION_FAN1 = RATED_LIMIT_OWNER_26,          /* 风机1通讯 */
    RATED_LIMIT_OWNER_27,
        RATED_LIMIT_OWNER_COMMUNICATION_FAN2 = RATED_LIMIT_OWNER_27,          /* 风机2通讯 */
    RATED_LIMIT_OWNER_28,
        RATED_LIMIT_OWNER_COMMUNICATION_METER = RATED_LIMIT_OWNER_28,         /* 电表通讯 */
    RATED_LIMIT_OWNER_29,
    RATED_LIMIT_OWNER_30,
    RATED_LIMIT_OWNER_31,
    /* Group_1 */
    RATED_LIMIT_OWNER_32,
    RATED_LIMIT_OWNER_33,
    RATED_LIMIT_OWNER_34,
    RATED_LIMIT_OWNER_35,
    RATED_LIMIT_OWNER_36,
    RATED_LIMIT_OWNER_37,
    RATED_LIMIT_OWNER_38,
    RATED_LIMIT_OWNER_39,
    RATED_LIMIT_OWNER_40,
    RATED_LIMIT_OWNER_41,
    RATED_LIMIT_OWNER_42,
    RATED_LIMIT_OWNER_43,
    RATED_LIMIT_OWNER_44,
    RATED_LIMIT_OWNER_45,
    RATED_LIMIT_OWNER_46,
    RATED_LIMIT_OWNER_47,
    /* Group_2 */
    RATED_LIMIT_OWNER_48,
    RATED_LIMIT_OWNER_49,
    RATED_LIMIT_OWNER_50,
    RATED_LIMIT_OWNER_51,
    RATED_LIMIT_OWNER_52,
    RATED_LIMIT_OWNER_53,
    RATED_LIMIT_OWNER_54,
    RATED_LIMIT_OWNER_55,
    RATED_LIMIT_OWNER_56,
    RATED_LIMIT_OWNER_57,
    RATED_LIMIT_OWNER_58,
    RATED_LIMIT_OWNER_59,
    RATED_LIMIT_OWNER_60,
    RATED_LIMIT_OWNER_61,
    RATED_LIMIT_OWNER_62,
    RATED_LIMIT_OWNER_63,
    /* Group_3 */
    RATED_LIMIT_OWNER_64,
    RATED_LIMIT_OWNER_65,
    RATED_LIMIT_OWNER_66,
    RATED_LIMIT_OWNER_67,
    RATED_LIMIT_OWNER_68,
    RATED_LIMIT_OWNER_69,
    RATED_LIMIT_OWNER_70,
    RATED_LIMIT_OWNER_71,
    RATED_LIMIT_OWNER_72,
    RATED_LIMIT_OWNER_73,
    RATED_LIMIT_OWNER_74,
    RATED_LIMIT_OWNER_75,
    RATED_LIMIT_OWNER_76,
    RATED_LIMIT_OWNER_77,
    RATED_LIMIT_OWNER_78,
    RATED_LIMIT_OWNER_79,
    
    RATED_LIMIT_OWNER_QTY,
} ratedLimitOwner_t;


typedef enum
{
    RATED_LIMIT_TYPE_CHRG = 0,
    RATED_LIMIT_TYPE_DISC,
    RATED_LIMIT_TYPE_QTY,
} ratedLimitType_t;


#if(RATED_LIMIT_TYPE_SEL == RATED_LIMIT_TYPE_ENTIRE)


/**
 * @brief 获取限额百分比
 */
int RatedLimit_GetPercentage(uint16_t *pValue);


/**
 * @brief 获取限额原因
 */
int RatedLimit_GetReason(uint16_t group, uint16_t *pValue);


/**
 * @brief 设置限额百分比
 */
int RatedLimit_SetPercentage(ratedLimitOwner_t owner, float percentage_0p01);


#elif(RATED_LIMIT_TYPE_SEL == RATED_LIMIT_TYPE_SEPARATE)


/**
 * @brief 获取限额百分比
 */
int RatedLimit_GetPercentage(ratedLimitType_t type, uint16_t *pValue);


/**
 * @brief 获取限额原因
 */
int RatedLimit_GetReason(ratedLimitType_t type, uint16_t group, uint16_t *pValue);


/**
 * @brief 设置限额百分比
 */
int RatedLimit_SetPercentage(ratedLimitOwner_t owner, ratedLimitType_t type, float percentage_0p01);


#endif


void RatedLimit_Init(void);
void RatedLimit_Thread(void *pPara);


#endif

